package com.sqstudio.exercise.chapter1_2
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.view.Viewport3D;
	
	public class FirstApplication extends Sprite
	{
		
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var viewport:Viewport3D;
		private var sphere:Sphere;
		private var renderEngine:BasicRenderEngine;
		
		public function FirstApplication()
		{
			
			this.scene = new Scene3D();
			this.camera = new Camera3D();
			this.viewport = new Viewport3D();
			addChild(this.viewport);
			this.sphere = new Sphere();
			this.scene.addChild(this.sphere);
			this.renderEngine = new BasicRenderEngine();
			
			this.addEventListener(Event.ENTER_FRAME,rendHandler);
			
		}
		private function rendHandler(e:Event):void
		{
			this.sphere.localRotationY ++;
			this.renderEngine.renderScene(this.scene,this.camera,this.viewport);
		}
	}
}